<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui">
<f:view contentType="text/html"/>	
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>
	<h:form>
		<h2>
		<h:outputText value="Cadastro de Produto"/>
		</h2>
		
		<h:panelGrid columns="2">
			<h:outputText value="Nome:"/>	
			<h:inputText id="nome" value="#{produtoBean.produto.nome}" />
			
			<h:outputText value="Descricao:"/>	
			<h:inputTextarea id="descricao" value="#{produtoBean.produto.descricao}" />

			<h:outputText value="Preco:"/>	
			<h:inputText id="preco" value="#{produtoBean.produto.preco}" />			
			
			<h:commandButton value="Gravar" action="#{produtoBean.grava}" />
		</h:panelGrid>
	</h:form>
	<br />

	<h:form>

		<h:dataTable var="p" value="#{produtoBean.produtos}">
			<h:column>
				<f:facet name="header">
					<h:outputText value="nome" />
				</f:facet>
				#{p.nome}
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Descricao" />
				</f:facet>
				#{p.descricao}
			</h:column>

			<h:column>
				<f:facet name="header">
					<h:outputText value="Preço" />
				</f:facet>
				#{p.preco}
			</h:column>
			
		<h:column>
				<f:facet name="header">
					<h:outputText value="Acçoes" />
				</f:facet>
				<h:column>
					<h:commandLink value="Remove" action="#{produtoBean.exclui}"  >
						<f:setPropertyActionListener value="#{p}" target="#{produtoBean.produto}"/>
					</h:commandLink>
					
				</h:column>
			</h:column>			
		</h:dataTable>
	</h:form>

</body>
</html>